{extend name="common/main"}

{block name="css"}
<link rel="stylesheet" href="/static/assets/css/bootstrap.min.css" />
<style>
    .lai{
        float: none;
        display:inline-block;
    }
</style>
{/block}

{block name="body"}
<body data-type="widgets">
{include file="common/index"}
<!-- 内容区域 -->
<!-- 内容区域 -->
<div class="tpl-content-wrapper">
    <div class="row-content am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                <h3>设备</h3>
                <div class="widget am-cf">
                        <!--<a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>-->

                    <div class="widget-body  am-fr">
                        <div class="am-btn-toolbar" >
                            {if $Think.session.user.type neq 0}
                            <div class="am-btn-group am-btn-group-xs" >
                                <a href="{:Url('add')}" class="am-btn am-btn-default am-btn-success" ><span class="am-icon-plus" ></span> 新增</a>
                            </div>
                            {/if}
                        </div>
                        {notempty name="$data.0"}
                        <a  href="{:url('export')}?outtime={$Request.get.outtime}" class="am-btn am-btn-primary am-radius" style=" padding: .3em 1em;float: right">导出Excel</a>

                        {/notempty}
                        <div class="am-u-sm-12">

                            <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>设备名称</th>
                                    <th>设备号</th>
                                    <th>使用者</th>
                                    <!--<th>激活时间</th>-->
                                    <th>到期时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach name="data" key="key" item="value"}
                                <tr class="gradeX">
                                    <td>{$value.id}</td>
                                    <td>{$value.nickname}</td>
                                    <td>{$value.name}</td>
                                    <td>{notempty name="$value.a_u_nickname"}{$value.a_u_nickname}{else}未绑定{/notempty}</td>
                                    <td>{if $value.expire_time=='0'}未激活{else}{$value.expire_time|date='Y-m-d H:i:s',###}{/if}</td>
                                    <td>
                                        <div class="tpl-table-black-operation">

                                            {if $value.equ_user=="0"}
                                            <a href="{:url('add')}?id={$value.id}">
                                                <i class="am-icon-pencil"></i> 修改
                                            </a>
                                            <a onclick="del_button({$value.id});" href="javascript:void(0);" href="javascript:;" class="tpl-table-black-operation-del">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                            {else}
                                            <a href="{:url('luyin_view')}?imei={$value.name}">
                                                <i class="am-icon-pencil"></i> 录音/通话
                                            </a>
                                            {/if}
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                                <!-- more data -->
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <div class="col-md-7 pull-right">
                        {$data->render()}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
{/block}

{block name="js"}
<script >
    // 录音
    function luyin_button($imei) {
        $token="4d9262b1a5da42779110baa9df648743";
        layer.confirm("确定录音？", {btn: ["确定","取消"], shade: 0.5}, function(){

            $.ajax({
                // url: "https://api.huixun.me/open/record/"+$imei,
                url:"{:url('luyin')}",
                type: 'POST',
                data: {
                    token:$token
                },
                dataType: 'json',
                // traditional:true,//防止深度序列化
                // cache:false,
                // async:false,
                success: function (res) {
                    console.log(res);
                    return false;

                    if(res.code != 200){
                        layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                        return false;

                    }else {
                        layer.closeAll('page');
                        location.reload();
                    }

                }
            });
        }, function () {});
    }

    // 删除按钮
    function del_button(id, className) {
        layer.confirm("确定删除？", {btn: ["确定","取消"], shade: 0.5}, function(){
            // 删除权限组
            $.post("{:url('del')}", {id: id}, function(res) {
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                    return false;
                }

                layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 1}, function() {
                    layer.closeAll('page');
                    location.reload();
                });
            });
        }, function () {});
    }
    //导出
    function exc_button() {
        $type= $("[name='type']").val();
        $display=$("[name='display']").val();
        // $where=[];
        // if ($type!=-1){
        //     $where['type']=$type;
        // }
        // if($display!=-1){
        //     $where['display']=$display;
        // }
        window.location.replace("{:url('export')}?type="+$type+"&display="+$display);

    }

</script>

{/block}